<?php slot('user', $user); ?>
<?php slot('sub', $sub); ?>
<?php slot('menu', $menu); ?>

<script>
    var hotels = [];
<?php foreach ($names as $h) { ?>
        var temp = {
            id: '<?php echo $h->getId() ?>',
            nameEn: '<?php echo $h->getNameEn() ?>',
            city_id: '<?php echo $h->getCityId() ?>'
        };
        hotels.push(temp);
<?php } ?>
    $(function() {
        insertSelectHotels($('.search_city select').val());

        $('.search_city select').change(function() {
            insertSelectHotels($(this).val());
        });
    });

    function insertSelectHotels(city_id) {
        $('.search_hotels select option').remove();
        var parentSelect = $('.search_hotels select');
        var firstOption = $('<option value="0">All</option>');
        (parentSelect).append(firstOption);

        $.each(hotels, function(i, v) {
            if (city_id != 0) {
                if (v.city_id == city_id) {
                    (parentSelect).append('<option value="' + v.id + '">' + v.nameEn + '</option>');
                }
            } else {
                (parentSelect).append('<option value="' + v.id + '">' + v.nameEn + '</option>');
            }
        });
    }
</script>

<div class="center">
    <div id="center_conteiner" class="clearfix">
        <div class="center_sub_conteiner">

            <div class="center_block">
                <div class="header_center_block"><span>Search</span></div>

                <div class="center_line">
                    <div class="search_city">
                        <label for="search_city_select">City</label>
                        <select id="search_city_select">
                            <option value="0" selected="selected">Please select a city</option>
                            <?php
                            foreach ($city as $c) {
                                if ($c->getCountryId() == 1) {
                                    echo '<option value="' . $c->getId() . '">' . $c->getNameEn() . '</option>';
                                }
                            }
                            ?>
                        </select>
                    </div>

                    <div class="search_check_in">
                        <label for="search_check_in_input">Check in</label>
                        <input type="text" id="search_check_in_input">
                        <img src="/web/images/icoCalendar.png"/>
                    </div>

                    <div class="search_night">
                        <label for="search_night_input">Night</label>
                        <select id="search_night_input"></select>
                    </div>

                    <div class="search_check_out">
                        <label for="search_check_out_input">Check out</label>
                        <input type="text" id="search_check_out_input">
                        <img src="/web/images/icoCalendar.png"/>
                    </div>
                </div>

                <div class="center_line">
                    <div class="search_hotels">
                        <label for="search_hotels_select">Hotel</label>
                        <select id="search_hotels_select"></select>
                    </div>

                    <div class="search_ranks">
                        <label for="search_ranks_slider">Rank</label>
                        <ul class="top">
                            <li><img src="/web/images/icoSmallStar.png"</li>
                            <li><img src="/web/images/icoSmallStar.png"</li>
                            <li><img src="/web/images/icoSmallStar.png"</li>
                            <li><img src="/web/images/icoSmallStar.png"</li>
                            <li><img src="/web/images/icoSmallStar.png"</li>
                        </ul>
                        <div id="search_ranks_slider"></div>
                        <ul class="down">
                            <li><img src="/web/images/icoSmallStar.png"</li>
                            <li><img src="/web/images/icoSmallStar.png"</li>
                            <li><img src="/web/images/icoSmallStar.png"</li>
                            <li><img src="/web/images/icoSmallStar.png"</li>
                            <li><img src="/web/images/icoSmallStar.png"</li>
                        </ul>
                    </div>
                </div>

                <div class="center_line_rooms"></div>

                <div class="center_line">
                    <div class="add_room">Add room</div>
                </div>

                <div class="user_civic">
                    <input type="radio" name="group_civic" id="civic_tourist" value="1" checked><label for="civic_tourist">Tourist</label>
                    <input type="radio" name="group_civic" id="civic_israeli" value="2"><label for="civic_israeli">Israeli</label>
                </div>

                <div class="center_line">
                    <input type="button" class="hotel_search_button" value="Search">
                </div>

            </div>

            <div class="center_block">
                <div class="header_center_block">
                    <span>Result</span>
                    <div class="right_header_block">String for message's of search result - errors or count of founded rooms, or advice of search</div>
                </div>

                <?php include_partial('dashboard/listhotel', array('hotels' => $hotels, 'pages' => $pages, 'page' => $page, 'sort' => $sort, 'sorts' => $sorts, 'search' => $search)) ?>
            </div>

        </div>
    </div>
</div>


<div class="loader_hotel">
    <img src="../images/loader4.gif"/>
</div>